package com.tring.ysyn.util.transcation;

import org.springframework.transaction.support.TransactionSynchronization;

/**
 * @author Tring
 * date 2022-11-11
 */
public class DoTransactionCompletion implements TransactionSynchronization {

    private Runnable runnable;

    public DoTransactionCompletion(Runnable runnable) {
        this.runnable = runnable;
    }

    @Override
    public void afterCompletion(int status) {
        //只有当我事务成功提交的时候，才去做处理
        if(status == TransactionSynchronization.STATUS_COMMITTED){
            this.runnable.run();
        }
    }
}
